/*
* Copyright (C) 2008-2009 J-P Nurmi jpnurmi@gmail.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
* License for more details.
*
* $Id: ircchannelbuffer.h 581 2009-05-19 16:40:38Z jpnurmi $
*/

#ifndef IRC_CHANNELBUFFER_H
#define IRC_CHANNELBUFFER_H

#include <ircglobal.h>
#include <ircbuffer.h>

namespace Irc
{
    class ChannelBufferPrivate;

    class IRC_EXPORT ChannelBuffer : public Buffer
    {
        Q_OBJECT
        Q_PROPERTY(QByteArray key READ key WRITE setKey)
        Q_PROPERTY(QByteArray mode READ mode WRITE setMode)
        Q_PROPERTY(QByteArray topic READ topic WRITE setTopic)

    public:
        ~ChannelBuffer();

        QByteArray key() const;
        Q_INVOKABLE void setKey(const QByteArray& key);

        QByteArray mode() const;
        Q_INVOKABLE void setMode(const QByteArray& mode);

        QByteArray topic() const;
        Q_INVOKABLE void setTopic(const QByteArray& topic);

        //QByteArray userMode(const QByteArray& user) const;
        //Q_INVOKABLE void setUserMode(const QByteArray& user, const QByteArray& mode);

        QList<QByteArray> names() const;

    public Q_SLOTS:
        void part(const QByteArray& reason = QByteArray());
        void kick(const QByteArray& user, const QByteArray& reason = QByteArray());
        void invite(const QByteArray& user);

    Q_SIGNALS:
        void joined(const QByteArray& prefix);
        void kicked(const QByteArray& prefix, const QByteArray& nick, const QByteArray& message);
        void modeChanged(const QByteArray& prefix, const QByteArray& mode, const QByteArray& args);
        void parted(const QByteArray& prefix, const QByteArray& message);
        void topicChanged(const QByteArray& prefix, const QByteArray& topic);

    protected:
        qint64 writeData(const char* data, qint64 maxSize);

    private:
        ChannelBuffer(const QByteArray& channel, const QByteArray& key, Session* session);
        Q_DECLARE_PRIVATE(ChannelBuffer)
        Q_DISABLE_COPY(ChannelBuffer)
        friend class Session;
        friend class SessionPrivate;
    };
}

#endif // IRC_CHANNELBUFFER_H
